package com.project.mapper;

import com.project.bean.UserBean;
import org.apache.ibatis.annotations.*;

@Mapper
public interface IUserMapper {
    /**
     * 用户登录，同时记录登录用户
     * @param code 账号
     * @param pwd 密码
     * @return 登录用户
     */
    @Select("select * from t_user where u_code=#{code} and u_pwd =#{pwd}")
    @ResultMap("userMap")
    UserBean login(@Param("code") String code, @Param("pwd") String pwd);

    /**
     * 用户注册
     * @param user 用户对象
     */
    @Insert("insert into t_user(u_code,u_pwd,u_mail,u_face,u_createDate)values" +
            "(#{code},#{pwd},#{mail},#{face},#{createDate})")
    void addUser(UserBean user);

    @Select("select * from t_user where u_code = #{code}")
    @ResultMap("userMap")
    UserBean findByName(String code);
}
